package com.ssm.design.state;

import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class OrderStateFactory {

    private Map<Integer, OrderState> stateMap = new HashMap<>();

    public void registerOrderState(Integer State, OrderState orderState) {
        this.stateMap.put(State, orderState);
    }

    public void switchState(Integer state) {
        this.stateMap.get(state).handle();
    }
}